f718c6b2a9cdeef417593fdaffa08f117d733e0c,core/languageDesign/transformation/source/jetbrains/mps/generator/template/TemplateProcessor.java,TemplateProcessor,createOutputNodesForTemplateNodeWithMacro,#NodeMacro#SNode#SNode#number#boolean#,151
Before Change
myGenerator.getDelayedChanges().addExecuteMapSrcNodeMacroChange(nodeMacro, childToReplaceLater, newInputNode, myGenerator);
} else {
boolean inputChanged = (newInputNode != inputNode);
if (inputChanged) {
pushInputHistory(inputNode, mappingName);
}
List<SNode> _outputNodes = createOutputNodesForTemplateNode(mappingName, templateNode, newInputNode, nodeMacrosToSkip + 1, inputChanged);
if (_outputNodes != null) outputNodes.addAll(_outputNodes);
if (inputChanged) {
popInputHistory();
} else if (registerTopOutput) {
myGenerator.addTopOutputNodesByInputNode(inputNode, _outputNodes);
}
}
} finally {
generationTracer.closeInputNode(newInputNode);
}
}
return outputNodes;
} else if (nodeMacro instanceof SwitchMacro) {
// $SWITCH$
TemplateSwitch templateSwitch = ((SwitchMacro) nodeMacro).getTemplateSwitch();
if (templateSwitch == null) {
myGenerator.showErrorMessage(inputNode, nodeMacro.getNode(), "error processing $SWITCH$ - bad TemplateSwitch reference");
return null;
}
SNode newInputNode = MacroUtil.getNewInputNode(nodeMacro, inputNode, myGenerator);
if (newInputNode != null) {
generationTracer.pushInputNode(newInputNode);
generationTracer.pushSwitch(templateSwitch.getNode());
RuleConsequence consequenceForCase = (RuleConsequence) myGenerator.getConsequenceForSwitchCase(newInputNode, templateSwitch);
SNode templateNodeForCase = null;
if (consequenceForCase != null) {
Pair<SNode, String> nodeAndMappingName = GeneratorUtil.getTemplateNodeFromRuleConsequence(consequenceForCase, newInputNode, nodeMacro.getNode(), myGenerator);
if (nodeAndMappingName == null) {
myGenerator.showErrorMessage(newInputNode, nodeMacro.getNode(), consequenceForCase.getNode(), "error processing $SWITCH$");
return null;
}
templateNodeForCase = nodeAndMappingName.o1;
if (nodeAndMappingName.o2 != null) {
mappingName = nodeAndMappingName.o2;
}
} else {
// for back compatibility
generationTracer.pushRule(templateSwitch.getNode());
TemplateDeclaration templateForSwitchCase = myGenerator.getTemplateForSwitchCase_deprecated(newInputNode, templateSwitch);
if (templateForSwitchCase != null) {
TemplateFragment fragment = GeneratorUtil.getFragmentFromTemplate(templateForSwitchCase, newInputNode, nodeMacro.getNode(), myGenerator);
if (fragment != null) {
mappingName = GeneratorUtil.getMappingName(fragment, mappingName);
templateNodeForCase = fragment.getParent().getNode();
}
}
}
boolean inputChanged = (newInputNode != inputNode);
if (inputChanged) {
pushInputHistory(inputNode, mappingName);
}
List<SNode> _outputNodes;
if (templateNodeForCase != null) {
_outputNodes = createOutputNodesForExternalTemplateNode(mappingName, templateNodeForCase, newInputNode, inputChanged);
} else {
// no switch-case found for the inputNode - continue with templateNode under the $switch$
_outputNodes = createOutputNodesForTemplateNode(mappingName, templateNode, newInputNode, nodeMacrosToSkip + 1, inputChanged);
}
if (_outputNodes != null) outputNodes.addAll(_outputNodes);
if (inputChanged) {
popInputHistory();
} else if (registerTopOutput) {
myGenerator.addTopOutputNodesByInputNode(inputNode, _outputNodes);
}
}
return outputNodes;
} else if (nodeMacro instanceof IncludeMacro) {
// $INCLUDE$
IncludeMacro includeMacro = (IncludeMacro) nodeMacro;
SNode newInputNode = MacroUtil.getNewInputNode(nodeMacro, inputNode, myGenerator);
if (newInputNode != null) {
generationTracer.pushInputNode(newInputNode);
TemplateDeclaration includeTemplate = includeMacro.getIncludeTemplate();
if (includeTemplate == null) {
myGenerator.showErrorMessage(newInputNode, null, nodeMacro.getNode(), "error processing $INCLIDE$ : no 'include template'");
return null;
}
generationTracer.pushTemplateNode(includeTemplate.getNode());
TemplateFragment fragment = GeneratorUtil.getFragmentFromTemplate(includeTemplate, newInputNode, nodeMacro.getNode(), myGenerator);
if (fragment == null) {
myGenerator.showErrorMessage(newInputNode, null, nodeMacro.getNode(), "error processing $INCLIDE$");
return null;
}
SNode templateForInclude = fragment.getParent().getNode();
mappingName = GeneratorUtil.getMappingName(fragment, mappingName);
boolean inputChanged = (newInputNode != inputNode);
if (inputChanged) {
pushInputHistory(inputNode, mappingName);
}
List<SNode> _outputNodes = createOutputNodesForExternalTemplateNode(mappingName, templateForInclude, newInputNode, inputChanged);
if (_outputNodes != null) outputNodes.addAll(_outputNodes);
if (inputChanged) {
popInputHistory();
} else if (registerTopOutput) {
myGenerator.addTopOutputNodesByInputNode(inputNode, _outputNodes);
}
} // for (SNode newInputNode : newInputNodes)
return outputNodes;
}
// $$
List<SNode> newInputNodes = MacroUtil.getNewInputNodes(nodeMacro, inputNode, myGenerator);
for (SNode newInputNode : newInputNodes) {
generationTracer.pushInputNode(newInputNode);
try {
boolean inputChanged = (newInputNode != inputNode);
if (inputChanged) {
After Change
}
boolean inputChanged = (newInputNode != inputNode);
if (inputChanged) {
pushInputHistory(inputNode, mappingName);
generationTracer.pushInputNode(newInputNode);
}
generationTracer.pushTemplateNode(includeTemplate.getNode());